package ui;

import service.*;

import java.util.Scanner;

public class DiscUI {
    private static Scanner si = new Scanner(System.in);

    public static void main(String[] args) {
        login();
    }

    public static void menu() {
        System.out.println("****************欢迎来到碟片管理系统****************");
        System.out.println("\t\t\t\t\t请选择：");
        System.out.println("\t\t\t\t\t1.新增碟片");
        System.out.println("\t\t\t\t\t2.显示全部碟片");
        System.out.println("\t\t\t\t\t3.出租碟片");
        System.out.println("\t\t\t\t\t4.删除碟片");
        System.out.println("\t\t\t\t\t5.归还碟片");
        System.out.println("\t\t\t\t\t6.出租热”星“");
        System.out.println("\t\t\t\t\t7.退出程序");
        System.out.println("<-><-><-><-><-><-><-><-><-><-><-><-><-><-><-><->");
    }

    public static int select() {
        int temp = si.nextInt();
        switch (temp) {
            case 1:
                addDisc();
                return 1;
            case 2:
                inquiry();
                return 2;
            case 3:
                rent();
                return 3;
            case 4:
                deleteDisc();
                return 4;
            case 5:
                dReturn();
                return 5;
            case 6:
                leaderboard();
                return 6;
            default:
                return 7;
        }
    }

    public static void login() {
        String name;
        String password;
        System.out.println("欢迎来到コーチャンの碟片管理系统！请先登录");
        System.out.println("请输入账户名：");
        name = si.next();
        System.out.println("请输入密码：");
        password = si.next();
        if (UserService.logined(name, password)) {
            int temp;
            do {
                menu();
                temp=select();
            } while (temp>0&&temp<=6);
            System.out.println("退出成功");
        }
    }


    public static void addDisc() {
        AddService as = new AddService();
        System.out.println("请输入碟片名");
        String sName = si.next();
        System.out.println("请输入碟片价格");
        int price = si.nextInt();
        as.addDService(sName, price);
    }

    public static void deleteDisc() {
        DeleteService ds = new DeleteService();
        System.out.println("请输入需要删除的碟片名称");
        String sName = si.next();
        ds.deleteDisc(sName);

    }

    public static void inquiry() {
        InquiryService is = new InquiryService();
        is.inquiryService();
    }

    public static void rent() {
        RentService rs = new RentService();
        System.out.println("请选择想要出租的碟片");
        inquiry();
        String sName = si.next();
        rs.rentService(sName);
    }

    public static void dReturn() {
        DReturnService drs = new DReturnService();
        System.out.println("请输入你需要归还的碟片名称");
        String name = si.next();
        drs.dReturnService(name);
    }

    public static void leaderboard() {
        LeaderboardService ls = new LeaderboardService();
        ls.leaderboardService();
    }
}